<?php

/**
 * \class side_customer_links
 * \brief handles business user sessions and menus
 * \author  Sicelo Cele
 * \author  Salman Noor
 */
class side_customer_links {

/**
 * \brief private data member to access functionality defined in class html_elements_builder
 */
    private $html_builder;

/**
 * \brief handles the business user session identities
 */
    private $session_user_name;

/**
 * \brief handles business user database access
 */
    private $customerUserDBObject;

/**
 * \brief constructor to initialise customer session variablle to store username
 */
    public function __construct($session_user_name) {
        $this->html_builder = new html_elements_builder();
        $this->customerUserDBObject = new database_tables_handler();
        if (isset($session_user_name)) {
            $this->session_user_name = $session_user_name;
        } else {
            $this->session_user_name = null;
            echo "Error. Customer Side Links Session variables are not set.";
        }
    }


 /**
 * \brief  builds the search menu to allow the user search for events
 * \return html content
 */
    private function buildSearchMenu() {
        $searchMenuStyle = "<style>
	.ui-autocomplete-category {
		font-weight: bold;
		padding: .2em .4em;
		margin: .8em 0 .2em;
		line-height: 1.5;
	}
	</style>";

        $buildSearchMenu = $searchMenuStyle;
        $buildSearchMenu .= "<div id='searchMenuContainer' class='ui-widget-content ui-corner-all'style='border:1px solid #CCCCCC;padding:20px 20px 20px 20px; float:left; width:90%;'> ";
        $buildSearchMenu .= "<h3>Search Menu</h3>";
        $buildSearchMenu .= "<label for='search'>Search for <i>event names</i> categorized into <i>event types</i>: </label><br>";
        $buildSearchMenu .= "<input id='search' />";
        $buildSearchMenu .= $this->html_builder->buildHiddenInput("hiddenSearchEventID", '') . "<br>";
        $buildSearchMenu .= $this->html_builder->buildButton("openSearchedEventByType", "See More Details", ".searchButton");
        $buildSearchMenu .= "</div>";
        return $buildSearchMenu;
    }

    
 /**
 * \brief  build extra functions of side links from the map window
 * \return html content
 */
    private function buildMainSideLinks() {
        $a = $this->html_builder->buildButton('Site', 'TEST Event Site', 'side_customer_links');
        $userDetails = $this->customerUserDBObject->getCustomerUserDetails($this->session_user_name);
        $sideLinksWindow = "<h3>Welcome " . $userDetails['cuser_fname'] . " " . $userDetails['cuser_lname'] . "</h3>";
        $sideLinksWindow .= "<div id='rightNavMainLinksHolder' class='ui-widget-content ui-corner-all'style='border:1px solid #CCCCCC;padding:20px 20px 20px 20px; float:left; width:90%;'> ";
        $sideLinksWindow .= $this->html_builder->buildButton("goBackToHome", "Go To Home Page", "sideMainNavLinks");
        $sideLinksWindow .= $this->html_builder->buildButton("seeCUserDetails", "See Your User Details", "sideMainNavLinks");
        $sideLinksWindow .= $this->html_builder->buildButton("seeCUserItenarary", "See and Edit Current Itinerary", "sideMainNavLinks");
        $sideLinksWindow .= "</div>";
        $sideLinksWindow .= "<div id='distanceSLiderHolder' class='ui-widget-content ui-corner-all'style='border:1px solid #CCCCCC;padding:20px 20px 20px 20px; float:left; width:90%;'> ";
        $sideLinksWindow .= "<h3>Distance Filter</h3>";
        $sideLinksWindow .= "<p><label for='distanceVariable'>Distance From Your Location:</label>";
        $sideLinksWindow .= "<span id='distanceVariable' style='border:0; font-weight:bold;' /></span></p>";
        $sideLinksWindow .= "<div id='distanceSlider'></div>";
        $sideLinksWindow .= "</div>";
        $sideLinksWindow .= $this->buildSearchMenu();
        return $sideLinksWindow;
    }


 /**
 * \return html content built using the buildMainSideLinks() method
 */
    public function showMainSideLinks() {
        return $this->buildMainSideLinks();
    }

}
?>
